import { ApiResponse, ArticleItem } from "../../types/data";
import { RootThunkAction } from "../../types/store";
import request from "../../utils/request";
export const getArticle = (id: number): RootThunkAction => {
  return async (dispatch) => {
    const res = await request.get<
      ApiResponse<{
        results: ArticleItem[];
      }>
    >(`/articles?channel_id=${id}&timestamp=${Date.now()}`);
    dispatch({
      type: "ARTICLE_SAVE",
      payload: res.data.data.results,
    });
  };
};
